package com.controller;

import com.entity.Role;
import com.service.IRoleService;
import com.until.Result;
import com.vo.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("role")
public class RoleController extends BaseController{
    @Resource
    private IRoleService roleService;

    @GetMapping("listAll")
    public Result listAll(){
        return success(roleService.listAll());
    }

    @PostMapping("listByParam")
    public Result listByParam(@RequestBody Page<Role> page){
        return success(roleService.listByParam(page));
    }

    @GetMapping("getByRoleId")
    public Result getByRoleId(Integer roleId){
        return success(roleService.getByRoleId(roleId));
    }

    @PostMapping("insert")
    public Result insert(@RequestBody Role role){
        return success(roleService.insert(role));
    }

    @PostMapping("update")
    public Result update(@RequestBody Role role){
        return success(roleService.update(role));
    }

    @DeleteMapping("delete")
    public Result delete(Integer roleId){
        return success(roleService.delete(roleId));
    }

    @GetMapping("listMenuIdByRoleId")
    public Result listMenuIdByRoleId(Integer roleId){
        return success(roleService.listMenuIdByRoleId(roleId));
    }

    @PostMapping("insertRoleAndMenu")
    public Result insertRoleAndMenu(Integer roleId,String ids){
        return success(roleService.insertRoleAndMenu(roleId,ids));
    }
}
